package cn.net.ecode.exception;

import cn.net.ecode.util.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName TPExceptionHandler
 * @Description 异常处理器
 * @Author AlanShelby
 * @Date 2019/8/29 0029 8:39
 * @Version 1.0
 */
@ControllerAdvice
public class TPExceptionHandler {

    /**
     * @ClassName TPExceptionHandler
     * @Description 处理自定义异常
     * @Author AlanShelby
     * @Date 2019/8/29 0029 8:39
     * @Version 1.0
     */
    @ResponseBody
    @ExceptionHandler(TPException.class)
    public R handleRRException(TPException e) {
        R r = new R();
        r.put("code", e.getCode());
        r.put("msg", e.getMessage());

        return r;
    }
}
